/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package service.enumerations;

import model.AlarmType;

/**
 *
 * @author dchapman
 */
public enum MashType {
    SINGLE_INFUSION(0),
    STEP(1),
    DECOCTION(2),
    SPARGE(3);
    
    private final int type;

    MashType(final int type) {
        this.type = type;
    }

    public int getType() {
        return type;
    }

    public static MashType getType(final String type) {
        return getType(Integer.parseInt(type));
    }
    
    public static MashType getType(final int type) {
        switch (type) {
        case 0:
            return SINGLE_INFUSION;
        case 1:
            return STEP;
        case 2:
            return DECOCTION;
        case 3:
            return SPARGE;
        default:
            throw new EnumConstantNotPresentException(AlarmType.class, String.valueOf(type));
        }
    }
    
    public static MashType getTypeByName(final String str) {
        if(str.equals("SINGLE_INFUSION")){
            return SINGLE_INFUSION;
        } else if(str.equals("STEP")){
            return STEP;
        } else if(str.equals("DECOCTION")){
            return DECOCTION;
        } else if(str.equals("SPARGE")){
            return SPARGE;
        } else {
            return SINGLE_INFUSION;
        }
    }
}
